package com.sleep.psy.external_server.business.psy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sleep.psy.external_server.business.psy.entity.PsySection;
import com.sleep.psy.external_server.business.psy.mapper.PsySectionMapper;
import com.sleep.psy.external_server.business.psy.service.PsySectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 提交分数详细表 服务实现类
 * </p>
 *
 * @author wenliguo
 * @since 2025-08-12
 */
@Service
public class PsySectionServiceImpl extends ServiceImpl<PsySectionMapper, PsySection> implements PsySectionService {

    @Autowired
    private PsySectionMapper psySectionMapper;

    /**
     * 通过报告id获取分数详细数据
     * @author wenliguo
     * @date 2025/6/9 14:13
     * @param reportId 报告id
     * @return java.util.List<com.sleep.psy.main_server.business2.evaluation.entity.PsySection>
     */
    @Override
    public List<PsySection> selectSectionByReportId(Long reportId) {
        QueryWrapper<PsySection> wrapper = new QueryWrapper<>();
        wrapper.eq("report_id", reportId);
        return psySectionMapper.selectList(wrapper);
    }

    /**
     * 通过报告id和答题顺序正序获取详细信息
     * @author wenliguo
     * @date 2025/7/25 09:09
     * @param reportId 报告id
     * @return java.util.List<com.sleep.psy.main_server.business2.evaluation.entity.PsySection>
     */
    @Override
    public List<PsySection> selectSectionByReportIdAndSort(Long reportId) {
        QueryWrapper<PsySection> wrapper = new QueryWrapper<>();
        wrapper.eq("report_id", reportId)
                .orderByAsc("sort_index");
        return psySectionMapper.selectList(wrapper);
    }
}
